<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">   
        <h2>{{students}}</h2>
    </div>
    <script src="./node_modules/vue/dist/vue.js"></script>
    <script src="./node_modules/axios/dist/axios.js"></script>
    <script>
        new Vue({
            el:"#app",
            data:{
                students:[],
            },
            created() {
                axios.get("http://127.0.0.1:5500/vue-07-lif&ajax/db.json")
                //如果不使用箭头函数，那么this就代表window对象
                    .then((res)=>{
                        console.log(res.data);
                        this.students=res.data;
                    })
                    .catch((error)=>{
                        console.log(error.message);
                    })
                    //无参数时候，小括号也不能舍去
                    .finally(()=>{
                        console.log("finally");
                    })
            },
        })
    </script>
</body>
</html>